<?php
require_once('./includes/headers.inc.php');
require_once('./top.php');

$error = FALSE;
if($_POST) {
    $headers = array(
        'From: ' . $_SESSION['user']['name'] . ' <' . $_SESSION['user']['username'] . '>',
        'X-Mailer: PHP/' . phpversion(),
    );
    $ret = mail($admin_email, 'Vertigo feedback', $_POST['feedback'], implode("\r\n", $headers));
    if($ret) {
        $_SESSION['msg'] = $msgMgr->get('feedback-success');
        header('Location: /');
        exit();
    } else {
        $error = $msgMgr->get('feedback-error');
    }
}

$replaces = array(
    'error'         => $msgMgr->formatMsg($error),
);
$lang = array(
    'header_feedback'   => $langMgr->get('header_feedback'),
    'btn_submit'        => $langMgr->get('btn_submit'),
);
$templateMgr->loadContent(basename(__FILE__, '.php'), array_merge($replaces, $lang));
?>
